#ifndef     __OTA_INFO_H
#define     __OTA_INFO_H

#include "./store.h"

namespace cfg {

struct OtaInfo {

    uint32_t pkg_size;
    uint32_t app_addr;
    uint32_t ota_data_addr;

    void init(uint32_t size) {

        pkg_size = size;
        app_addr = pub_driver::flash::APP_ADDR;
        ota_data_addr = pub_driver::flash::OTA_DATA_ADDR;
    }

    void reset() {
        pkg_size = 0;
        app_addr = 0;
        ota_data_addr = 0;
    }

    bool verify() const {

        return (pkg_size > 0) && 
            (pkg_size < pub_driver::flash::APP_SIZE) &&
            (app_addr == pub_driver::flash::APP_ADDR) &&
            (ota_data_addr == pub_driver::flash::OTA_DATA_ADDR);
    }
};

extern Store<OtaInfo, pub_driver::flash::OTA_INFO_ADDR> otaInfo;

}


#endif
